﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
    /// <summary>
    /// 部门逻辑类
    /// </summary>
    public class HRDept
    {
        /// <summary>
        /// 部门数据类
        /// </summary>
        private DAL.HRDept hrDeptDAL = new DAL.HRDept();
        public HRDept()
        {
        }
        /// <summary>
        /// 获取某单位所有部门的编号、名称、上级的编号
        /// <creator>wangl</creator>
        /// <date>2013-09-10</date>
        /// </summary>
        /// <param name="entityNO"></param>
        /// <returns></returns>
        public List<Model.HRDept> GetAllDeptNoAndName(string entityNO)
        {
            List<Model.HRDept> deptList = new List<Model.HRDept>();
            DataSet ds = hrDeptDAL.GetAllDeptNoAndName(entityNO);
            Model.HRDept model;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                model = new Model.HRDept();
                model.FDeptNo = row["FDeptNo"].ToString();
                model.FDeptName = row["FDeptName"].ToString();
                if (row["FParentDeptNo"].ToString() != string.Empty)
                {
                    model.FParentDeptNo = row["FParentDeptNo"].ToString();
                }

                deptList.Add(model);
            }

            return deptList;
        }

        public bool IsFIsAgencyByDeptNo(string deptno)
        {
            return hrDeptDAL.IsFIsAgencyByDeptNo(deptno);

        }
        public List<Model.HRDept> GetAllDeptByEntityNoFIsAgency(string entityNO)
        {
            List<Model.HRDept> deptList = new List<Model.HRDept>();
            DataSet ds = hrDeptDAL.GetAllDeptByEntityNoFIsAgency(entityNO);
            Model.HRDept model;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                model = new Model.HRDept();
                model.FDeptNo = row["FDeptNo"].ToString();
                model.FDeptName = row["FDeptName"].ToString();
                if (row["FParentDeptNo"].ToString() != string.Empty)
                {
                    model.FParentDeptNo = row["FParentDeptNo"].ToString();
                }

                deptList.Add(model);
            }

            return deptList;
        }
        public string GetFShowContent(string entityNO, string FDeptNo)
        {
            return hrDeptDAL.GetFShowContent(entityNO, FDeptNo);
        }
        /// <summary>
        /// 获取部门名称
        /// <creator>wangl</creator>
        /// <date>2013-09-25</date>
        /// </summary>
        /// <param name="fEntityNo">组织机构编号</param>
        /// <param name="fDeptNo">部门编号</param>
        /// <returns>部门名称</returns>
        public string GetDeptName(string entityNo, string deptNo)
        {
            return hrDeptDAL.GetDeptName(entityNo, deptNo);
        }
    }
}
